package com.spring.sunflower.common

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.spring.sunflower.R
import com.spring.sunflower.bean.BalanceBean

/**
 * Created by Kevin on 2021/7/17<br/>
 *
 * Describe:<br/>
 */
class BalanceAdapter(layoutResId: Int, data: MutableList<BalanceBean.Data>?) :
    BaseQuickAdapter<BalanceBean.Data, BaseViewHolder>(layoutResId, data) {
    override fun convert(holder: BaseViewHolder, item: BalanceBean.Data) {
        holder.setText(R.id.tvMoneyNum, item.goldCoin)
        holder.setText(R.id.tvRMB, "￥${item.money}")
        var tvDonate = holder.getView<TextView>(R.id.tvDonate)
//        if (item.vipDonate == "0") {
//            tvDonate.visibility = View.INVISIBLE
//        } else {
//            tvDonate.visibility = View.VISIBLE
//            tvDonate.text = "VIP赠送${item.money}"
//        }
        var tvCornerMark = holder.getView<TextView>(R.id.tvCornerMark)
        if (item.firstValid == "1") {
            tvCornerMark.visibility=View.VISIBLE
        }else{
            tvCornerMark.visibility=View.GONE
        }
        val clContainer = holder.getView<ConstraintLayout>(R.id.cl_container)
        val ivChecked = holder.getView<ImageView>(R.id.iv_checked)
        if (item.checked) {
            clContainer.background = context.getDrawable(R.drawable.bg_shape_charge_checked)
            ivChecked.visibility = View.VISIBLE
        } else {
            ivChecked.visibility = View.GONE
            clContainer.background = context.getDrawable(R.drawable.bg_shape_gray)

        }


    }
}